﻿using Internal.Runtime.Models;

namespace Runtime.Models {

    /// <summary>
    /// 服务器数据
    /// </summary>
    public interface IDFR_ServerModel : IDFR_Model {

        /// <summary>
        /// 运行时ID
        /// </summary>
        int InstanceID { get; }

        /// <summary>
        /// ID
        /// </summary>
        int ID { get; }

        /// <summary>
        /// IP
        /// </summary>
        string IP { get; }

        /// <summary>
        /// 端口
        /// </summary>
        int Port { get; }

        /// <summary>
        /// 名称
        /// </summary>
        string Name { get; }

        /// <summary>
        /// 是否是安全连接
        /// </summary>
        bool IsSecure { get; }

        string GetStorageKey();
    }

    [Implement(typeof(IDFR_ServerModel))]
    internal sealed class DFR_ServerModel : DFR_Model, IDFR_ServerModel, IDFR_ServerModelInternal {

        public int InstanceID { get; private set; }

        public int ID { get; private set; }

        public string IP { get; private set; }

        public int Port { get; private set; }

        public string Name { get; private set; }

        public bool IsSecure { get; private set; }

        void IDFR_ServerModelInternal.Initialize(int instanceID, int id, string name, string ip, int port, bool isSecure) {
            InstanceID = instanceID;
            ID = id;
            IP = ip;
            Name = name;
            Port = port;
            IsSecure = isSecure;
        }

        public string GetStorageKey() => IP;
    }
}

namespace Internal.Runtime.Models {

    public interface IDFR_ServerModelInternal {

        void Initialize(int instanceID, int id, string name, string ip, int port, bool IsSecure);
    }
}
